fix(trace stats): Configure span kind and peer tag for agent-side stats#1189
Open
lucaspimentel wants to merge 12 commits into
Open
fix(trace stats): Configure span kind and peer tag for agent-side stats#1189lucaspimentel wants to merge 12 commits into
lucaspimentel wants to merge 12 commits into
Conversation
c06bc9b to
2eb4403
Compare
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR configures Bottlecap’s SpanConcentrator to match the Go agent defaults for (1) which span.kind values are eligible for stats computation and (2) which peer-related tag keys are used to populate per-dependency peer_tags, closing gaps in agent-side trace stats aggregation.
Changes:
- Configure
SpanConcentratorwith the Go agent’s default computed span kinds (client,server,producer,consumer) instead of an empty list. - Configure
SpanConcentratorwith the Go agent’s default peer tag key set (basePeerTags) instead of an empty list. - Add end-to-end tests for span-kind-based stats eligibility and peer tag population in emitted stats.
litianningdatadog
approved these changes
Jun 11, 2026
litianningdatadog
approved these changes
Jun 11, 2026
4ce8868 to
5e31b4f
Compare
Tests verify that StatsConcentratorService computes stats for spans with span.kind and populates peer_tags in output. Both tests currently fail due to empty span_kinds_stats_computed and peer_tag_keys vecs passed to SpanConcentrator::new(). 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Pass STATS_ELIGIBLE_SPAN_KINDS and DEFAULT_PEER_TAG_KEYS to SpanConcentrator::new() to match the Go agent defaults. This enables stats for OTel spans with span.kind and adds per-dependency granularity via peer tags for client/producer/consumer spans. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Cover the concentrator's span-kind and peer-tag eligibility through the full concentrator -> flusher -> intake path, verifying both survive msgpack/gzip serialization.
5e31b4f to
a652afd
Compare
The enrich_ctx_keeps_tracer_set_cold_start_trace_id_without_tracer_detected test calls setup(), which spawns a Tokio task, but was annotated with #[test] instead of #[tokio::test], causing a "no reactor running" panic. Match its sibling test and use #[tokio::test] async fn. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Configure
SpanConcentratorin bottlecap with the Go agent's defaultComputeStatsBySpanKindspan kinds andbasePeerTagspeer tag keys, fixing two gaps in agent-side trace stats computation:APMSVLS-464:span_kinds_stats_computedwas empty, so non-top-level, non-measured spans withspan.kind=server/client/producer/consumer) were silently excluded from stats.APMSVLS-463:peer_tag_keyswas empty, so client/producer/consumer spans had no per-dependency granularity in stats output (e.g., all S3 buckets, DynamoDB tables, Kafka topics lumped together).Changes
STATS_ELIGIBLE_SPAN_KINDSconstant (4 span kinds matching the Go agent'sKindsComputed)DEFAULT_PEER_TAG_KEYSconstant (43 peer tag keys matching the Go agent'sbasePeerTagsfrommappings.json)SpanConcentrator::new()instead of empty vecsStatsConcentratorServicepipeline for both featuresFollow-up
Both constants are hand-copied from the Go agent (
KindsComputedandbasePeerTags), which is the source of truth, and the same lists are also duplicated inserverless-components. A future refactor should keep the Rust agents in sync with the Go agent rather than each maintaining its own copy.Testing
test_span_kind_stats_computed: sends a non-root, non-measured client span through the service, verifies stats are produced withspan_kind="client"test_peer_tags_populated: sends a client span withdb.instanceanddb.systemmeta, verifiespeer_tagscontains both in the stats outputstats_span_kind_through_fake_intake: feeds a non-root, non-measuredserverspan through the full concentrator → flusher → fake-intake path, asserts the decodedStatsPayloadcarriesspan_kind="server"stats_peer_tags_through_fake_intake: feeds aclientspan withdb.instance/db.systemmeta through the same path, asserts the decodedpeer_tagscontain both keys after serialization